﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Showroom.BLL;

namespace ShowroomMobile
{
    public partial class Product : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadBannerLeft();
                LoadBannerRight();
            }
        }

        private void LoadBannerLeft()
        {
            try
            {
                Banners banner = new Banners();
                banner.Where.ID.Value = 1;
                banner.Where.Active.Value = true;
                banner.Query.Load();
                if (banner.RowCount > 0)
                {
                    bannerLeft.Attributes.Add("href", banner.s_URL);
                    bannerLeft.InnerHtml = string.Format("<img src='{0}' class='banner' />", Utilities.GetKeySetting("PathUploadBanner") + "/" + banner.s_FileName);
                }
                else
                {
                    bannerLeft.Attributes.Add("style", "display:none");
                }
            }
            catch (Exception ex)
            {
                ErrorLog.WriteToFile("Product.master.cs", "LoadBannerLeft", ex.StackTrace);
            }
        }

        private void LoadBannerRight()
        {
            try
            {
                Banners banner = new Banners();
                banner.Where.ID.Value = 4;
                banner.Where.Active.Value = true;
                banner.Query.Load();
                if (banner.RowCount > 0)
                {
                    bannerRight.Attributes.Add("href", banner.s_URL);
                    bannerRight.InnerHtml = string.Format("<img src='{0}' class='banner' />", Utilities.GetKeySetting("PathUploadBanner") + "/" + banner.s_FileName);
                }
                else
                {
                    bannerRight.Attributes.Add("style", "display:none");
                }
            }
            catch (Exception ex)
            {
                ErrorLog.WriteToFile("Product.master.cs", "LoadBannerLeft", ex.StackTrace);
            }
        }
    }
}